﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Sample09_Default : JavaScriptCodeBehind.Page
{

    private Random rand = new Random();

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if ((e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.Item))
        {
            Parent p = (Parent)e.Item.FindControl("Parent1");
            TextBox txt = (TextBox) p.FindControl("TextBox1");
            txt.Text = this.rand.Next(30).ToString();
        }
    }
    protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if ((e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.Item))
        {
            Parent p = (Parent)e.Item.FindControl("Parent1");
            TextBox txt = (TextBox) p.FindControl("TextBox1");
            txt.Text = this.rand.Next(30).ToString();
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

        int total;

        try
        {
            total = int.Parse(this.txtQtd.Text);
        }
        catch
        {
            this.rfvTxtQtd.IsValid = false;
            return;
        }

        DataTable dt = new DataTable();
        dt.Columns.Add("column1");

        for (int i = 0; i < total; i++)
        {
            dt.Rows.Add(dt.NewRow());
        }

        this.Repeater1.DataSource = dt;
        this.Repeater1.DataBind();

        dt = new DataTable();
        dt.Columns.Add("column1");
                
        for (int i = 0; i < total; i++)
        {
            dt.Rows.Add(dt.NewRow());
        }

        this.Repeater2.DataSource = dt;
        this.Repeater2.DataBind();

    }
}
